#pragma once

template <class T>
class Singleton
{
public:
	static T* Instance()
	{
		if (Instance_ == NULL)
		{
			static CGarbo cGarbo;		//垃圾收集
			Instance_ = new T;
		}
		return  Instance_;
	}
private:
	static T*  Instance_;
	class CGarbo // 它的唯一工作就是在析构函数中删除SingleTon的实例  
	{
	public:
		~CGarbo()
		{
			if (Singleton::Instance_ != NULL)
				delete Singleton::Instance_;
		}
	};
	Singleton(void);
	Singleton(const Singleton&);
	Singleton& operator= (const Singleton&);
};

template <class T>
T* Singleton<T>::Instance_ = NULL;